// ==========================================================================
// 云捷GO自动生成数据库操作代码，无需手动修改，重新生成会自动覆盖.
// 生成日期：2021-07-26 15:16:14
// 生成路径: app/model/module/news/news_entity.go
// 生成人：gfcms
// ==========================================================================

package news

import (
	"database/sql"
	"github.com/gogf/gf/database/gdb"
	"github.com/gogf/gf/os/gtime"
)

// Entity is the golang structure for table t_news.
type Entity struct {
	Id          int64       `orm:"id,primary" json:"id"`           //
	Catid       int         `orm:"catid" json:"catid"`             // 栏目名称
	Title       string      `orm:"title" json:"title"`             // 标题
	Thumb       string      `orm:"thumb" json:"thumb"`             // 缩略图
	Description string      `orm:"description" json:"description"` // 简介
	Author      string      `orm:"author" json:"author"`           // 作者
	Views       int         `orm:"views" json:"views"`             //阅读量
	Zan         int         `orm:"zan" json:"zan"`                 //点赞数
	Top         int         `orm:"top" json:"top"`                 //置顶
	Indexshow   int         `orm:"indexshow" json:"indexshow"`     //首页显示
	Content     string      `orm:"content" json:"content"`         //内容
	Listorder   int         `orm:"listorder" json:"listorder"`     // 排序
	Status      int         `orm:"status" json:"status"`           //
	CreateTime  *gtime.Time `orm:"create_time" json:"create_time"` // 创建时间
	UpdateTime  *gtime.Time `orm:"update_time" json:"update_time"` // 修改时间
	CreateBy    string      `orm:"create_by" json:"create_by"`     // 创建人
	UpdateBy    string      `orm:"update_by" json:"update_by"`     // 更新人
}

// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
// the data and where attributes for empty values.
func (r *Entity) OmitEmpty() *arModel {
	return Model.Data(r).OmitEmpty()
}

// Inserts does "INSERT...INTO..." statement for inserting current object into table.
func (r *Entity) Insert() (result sql.Result, err error) {
	return Model.Data(r).Insert()
}

// Replace does "REPLACE...INTO..." statement for inserting current object into table.
// If there's already another same record in the table (it checks using primary key or unique index),
// it deletes it and insert this one.
func (r *Entity) Replace() (result sql.Result, err error) {
	return Model.Data(r).Replace()
}

// Save does "INSERT...INTO..." statement for inserting/updating current object into table.
// It updates the record if there's already another same record in the table
// (it checks using primary key or unique index).
func (r *Entity) Save() (result sql.Result, err error) {
	return Model.Data(r).Save()
}

// Update does "UPDATE...WHERE..." statement for updating current object from table.
// It updates the record if there's already another same record in the table
// (it checks using primary key or unique index).
func (r *Entity) Update() (result sql.Result, err error) {
	return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
}

// Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
func (r *Entity) Delete() (result sql.Result, err error) {
	return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
}
